package com.semicolon_dtn;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Display;
import android.view.Menu;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.LinearLayout;

public class MainActivity extends Activity {
	LinearLayout layout;
	
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        layout=(LinearLayout)findViewById(R.id.back_layout);
	    layout.setBackgroundResource(R.drawable.back);	//background image
	    
	    //display size
	    Display display =  ((WindowManager)getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
	    int scrWidth = display.getWidth();
	    
	    
	    Button btn1= new Button(this);
	    Button btn2= new Button(this);
	    Button btn3= new Button(this);
	    
	    btn1.setBackgroundDrawable(getResources().getDrawable(R.drawable.menu1));
	    btn2.setBackgroundDrawable(getResources().getDrawable(R.drawable.menu2));
	    btn3.setBackgroundDrawable(getResources().getDrawable(R.drawable.menu4));
	    btn1.setLayoutParams(new LinearLayout.LayoutParams(scrWidth/4, LinearLayout.LayoutParams.WRAP_CONTENT)); 
	    btn2.setLayoutParams(new LinearLayout.LayoutParams(scrWidth/4, LinearLayout.LayoutParams.WRAP_CONTENT));
	    btn3.setLayoutParams(new LinearLayout.LayoutParams(scrWidth/4, LinearLayout.LayoutParams.WRAP_CONTENT));
	    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams ( LinearLayout.LayoutParams.WRAP_CONTENT,  LinearLayout.LayoutParams.WRAP_CONTENT);
	    layoutParams.setMargins (10, 50, 10, 10);
	    btn1.setLayoutParams (layoutParams);
	    btn2.setLayoutParams (layoutParams);
	    btn3.setLayoutParams (layoutParams);
	    
	    btn1.setOnClickListener(new Button.OnClickListener() {
			public void onClick(View v) {					
				Intent intent =  new Intent("android.intent.action.REGISTER");
				startActivity(intent);		
			}
       });
       
       btn2.setOnClickListener(new Button.OnClickListener() {
			public void onClick(View v) {
				Intent intent =  new Intent("android.intent.action.VIEWACTIVITY");
				startActivity(intent);		
			}
       });
       
       btn3.setOnClickListener(new Button.OnClickListener() {
			public void onClick(View v) {
				android.os.Process.killProcess(android.os.Process.myPid()); 
			}
      });
       
       layout.addView(btn1);
       layout.addView(btn2);
       layout.addView(btn3);

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
}
